<?php
/**
* @version              $Id: view.html.php 9764 2007-12-30 07:48:11Z ircmaxell $
* @package              Joomla
* @subpackage   Poll
* @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license              GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.view');

class amapViewliste_adherents_statuts extends JView {

var $amap;

        function display($tpl = null)
        {
   $mainframe =& JFactory::getApplication();

                $database =& JFactory::getDBO();
                $document =& JFactory::getDocument();
                $user =& JFactory::getUser();


$ida=$mainframe->getUserState('amap_ida');

// pour que la page  ne s'affiche pas en lien direct non connecté
if ($ida==0) return;


$html='<html>';
$html.='<div style="text-align:left;"><strong>Liste des adhésions et leur statut  à la période Décembre à Mai 2015 au '.date('d/m/Y').'</strong></div><br>';
$html.='Pour valider une adhésion à l\'AMAP et au contrat Décembre à Mai 2015, utiliser le menu "Gestion des adhérents et des membres du Comité" dans le menu Comité:<br>';
$html.='Statut=<span style=color:red>A</span> signifie "à valider"<br>';
$html.='Statut=<span style=color:green><strong>V</strong></span> signifie "validé"<br>';
$sql="SELECT amap_adherent.Nom,amap_adherent.Prenom,amap_adherent.Email,amap_adherent.Mobile,amap_adhesion.Statut,amap_adhesion.Date  FROM amap_adherent
LEFT JOIN amap_adhesion ON amap_adherent.IDA=amap_adhesion.IDA
ORDER BY amap_adherent.Nom,amap_adherent.Prenom";



$database->setQuery( $sql);
$liste=$database->loadRowList();
//print_r($liste);

$html.="<TABLE border='1'><TR><TD>Nom</TD><TD>Prenom</TD><TD>email</TD><TD>Mobile</TD><TD>Statut</TD><TD>Date</TD></TR>";
$nb=$nba=0;
foreach ($liste as $adherent)
{
$nb=$nb+1;
$html.='<TR>';
//      print_r($adherent);
        $html.= '<TD>'.$adherent['0'].'<TD>'.$adherent['1'].'</TD><TD>'.$adherent['2'].'</TD><TD>'.$adherent['3'].'</TD>';
if ($adherent['4']=='V') {$html.='<TD align=\'center\'><span style=color:green><strong>'.$adherent['4'].'</strong></TD>';$nbV=$nbV+1;}
else {$html.='<TD align=\'center\'><span style=color:red><strong>'.$adherent['4'].'</strong></TD>';$nbA=$nbA+1;}

$html.='</TD><TD>'.$adherent['5'].'</TD>' ;

$html.='<TR>';
}
$html.="</TABLE>";

$html.= '<br>Nombre d\'adherents validés :'.$nbV.'<br>';
$html.= '<br>Nombre d\'adherents à valider :'.$nbA.'<br>'; 
echo $html;
//contratPDF($html,$nom_contrat);
}
}
?>
